package com.jvup.gameshow.model.viewModel.impl;

import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView.Adapter;
import androidx.recyclerview.widget.RecyclerView.LayoutManager;

import com.jvup.common.support.base.BaseViewModel;
import com.jvup.common.widget.adapter.auto.AutoVariable;
import com.jvup.common.widget.adapter.auto.SummerRecyclerBindAdapter;
import com.jvup.common.widget.adapter.auto.annotation.AdapterEntityBind;
import com.jvup.gameshow.R;
import com.jvup.gameshow.databinding.LayoutMallProductItemBinding;

import java.util.ArrayList;

public class MallViewModel extends BaseViewModel {

    private final ArrayList<MallProductItemViewModel> productItemViewModelList = new ArrayList();
    {
        productItemViewModelList.add(new MallProductItemViewModel());
        productItemViewModelList.add(new MallProductItemViewModel());
        productItemViewModelList.add(new MallProductItemViewModel());
        productItemViewModelList.add(new MallProductItemViewModel());
        productItemViewModelList.add(new MallProductItemViewModel());
        productItemViewModelList.add(new MallProductItemViewModel());
        productItemViewModelList.add(new MallProductItemViewModel());
        productItemViewModelList.add(new MallProductItemViewModel());
        productItemViewModelList.add(new MallProductItemViewModel());
        productItemViewModelList.add(new MallProductItemViewModel());
        productItemViewModelList.add(new MallProductItemViewModel());
        productItemViewModelList.add(new MallProductItemViewModel());
        productItemViewModelList.add(new MallProductItemViewModel());
        productItemViewModelList.add(new MallProductItemViewModel());
    }

    private final SummerRecyclerBindAdapter adapter = new SummerRecyclerBindAdapter(productItemViewModelList);

    public Adapter getAdapter() {
        return adapter;
    }
    public LayoutManager getLayoutManager() {
        return new GridLayoutManager(null, 2);
    }


    @AdapterEntityBind(viewRid = R.layout.layout_mall_product_item)
    public class MallProductItemViewModel extends BaseObservable implements AutoVariable<LayoutMallProductItemBinding> {

        @Override
        public void bindVariable(LayoutMallProductItemBinding viewBind) {
            viewBind.setMallProductItemViewModel(this);
        }

        @Bindable
        public String getProductImage() {
            return "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1605561947746&di=a30acec35b005a0785bed915898bf0b3&imgtype=0&src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201711%2F30%2F20171130131318_CwXLM.thumb.400_0.jpeg";
        }
        @Bindable
        public CharSequence getProductName() {
            return "小鳄鱼";
        }
        @Bindable
        public CharSequence getIntroduction() {
            return "这是一只可爱的小鳄鱼，可以买一些放在家里";
        }
        @Bindable
        public CharSequence getPrice() {
            return "￥24.3";
        }
        @Bindable
        public CharSequence getOriginalPrice() {
            return "￥24.3";
        }
    }

} 
